﻿// Decompiled with JetBrains decompiler
// Type: DnProcessSimulateCommands.ExternalConnections.CUiECExternalConnectionsGridWrapper
// Assembly: DnProcessSimulateCommands, Version=2402.0.0.890, Culture=neutral, PublicKeyToken=null
// MVID: A885D881-AEDF-447E-852A-6F13102E089C
// Assembly location: C:\Program Files\Tecnomatix_2402\eMPower\DotNetCommands\DnProcessSimulateCommands.dll

using C1.Win.C1FlexGrid;
using C1.Win.C1FlexGrid.Util.BaseControls;
using DnProcessSimulateCommands.ExternalConnections.Res;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Windows.Forms;
using Tecnomatix.Engineering.Ui48;


namespace DnProcessSimulateCommands.ExternalConnections;

public class CUiECExternalConnectionsGridWrapper : TxFlexGridExtension
{
  internal const string COLUMN_NAME = "Column_Name";
  internal const string COLUMN_TYPE = "Column_Type";
  internal const string COLUMN_OPC_SERVER = "Column_OpcServer";
  internal const string COLUMN_ITEM_HEADER = "Column_ItemHeader";
  internal const string COLUMN_NAME_SPACE_INDEX = "Column_NameSpaceIndex";
  internal const string COLUMN_INSTANCE_NAME = "Column_InstanceName";
  internal const string COLUMN_COM_ELEMENT = "COMM_Element";
  internal const string COLUMN_MAP_SIGNALS_BY = "Column_MapSignalsBy";
  private const string STYLE_NORMAL_CONNECTION_NAME = "connectionName_Normal";
  private const string STYLE_SELECT_CONNECTION_NAME = "connectionName_Select";
  private const string STYLE_NORMAL_CONNECTION_TYPE = "connectionType_Normal";
  private const string STYLE_SELECT_CONNECTION_TYPE = "connectionType_Select";
  private const string STYLE_NORMAL_OPC_SERVER = "opcServer_Normal";
  private const string STYLE_SELECT_OPC_SERVER = "opcServer_Select";
  private const string STYLE_NORMAL_ITEM_HEADER = "itemHeader_Normal";
  private const string STYLE_SELECT_ITEM_HEADER = "itemHeader_Select";
  private const string STYLE_NORMAL_NAME_SPACE_INDEX = "namespaceIndex_Normal";
  private const string STYLE_SELECT_NAME_SPACE_INDEX = "namespaceIndex_Select";
  private const string STYLE_SELECT_PLC_PROGRAM_PATH = "plcProgramPath_Select";
  private const string STYLE_NORMAL_INSTANCE_NAME = "instanceName_Normal";
  private const string STYLE_SELECT_INSTANCE_NAME = "instanceName_Select";
  private const string STYLE_NORMAL_COM_ELEMENT = "comElement_Normal";
  private const string STYLE_SELECT_COM_ELEMENT = "comElement_Select";
  private const string STYLE_NORMAL_MAP_SIGNALS_BY = "mapSignalsBy_Normal";
  private const string STYLE_SELECT_MAP_SIGNALS_BY = "mapSignalsBy_Select";
  private IContainer components;

  internal event CUiECExternalConnectionsGridWrapper.CustomEditRequestEventHandler CustomEditRequest;

  public CUiECExternalConnectionsGridWrapper() => this.InitializeComponent();

  internal List<CApECBaseNode> Nodes
  {
    get
    {
      RowCollection rows = ((C1FlexGridBase) this).Rows;
      List<CApECBaseNode> nodes = new List<CApECBaseNode>();
      foreach (RowCol rowCol in (IEnumerable) rows)
      {
        if (rowCol.UserData is CApECBaseNode userData)
          nodes.Add(userData);
      }
      return nodes;
    }
  }

  internal List<CApECBaseNode> SelectedNodes
  {
    get
    {
      RowCollection selected = ((C1FlexGridBase) this).Rows.Selected;
      List<CApECBaseNode> selectedNodes = new List<CApECBaseNode>(((RowColCollection) selected).Count);
      foreach (RowCol rowCol in (IEnumerable) selected)
      {
        if (rowCol.UserData is CApECBaseNode userData)
          selectedNodes.Add(userData);
      }
      return selectedNodes;
    }
  }

  internal List<CApECExternalConnectionNode> ConnectionNodes
  {
    get
    {
      RowCollection rows = ((C1FlexGridBase) this).Rows;
      List<CApECExternalConnectionNode> connectionNodes = new List<CApECExternalConnectionNode>();
      foreach (RowCol rowCol in (IEnumerable) rows)
      {
        if (rowCol.UserData is CApECExternalConnectionNode userData)
          connectionNodes.Add(userData);
      }
      return connectionNodes;
    }
  }

  internal List<CApECExternalConnectionNode> SelectedConnectionNodes
  {
    get
    {
      RowCollection selected = ((C1FlexGridBase) this).Rows.Selected;
      List<CApECExternalConnectionNode> selectedConnectionNodes = new List<CApECExternalConnectionNode>(((RowColCollection) selected).Count);
      foreach (RowCol rowCol in (IEnumerable) selected)
      {
        if (rowCol.UserData is CApECExternalConnectionNode userData)
          selectedConnectionNodes.Add(userData);
      }
      return selectedConnectionNodes;
    }
  }

  protected virtual void MarkAllSelected()
  {
    ((Control) this).SuspendLayout();
    foreach (RowCol rowCol in (IEnumerable) ((C1FlexGridBase) this).Rows.Selected)
    {
      if (rowCol.UserData is CApECBaseNode userData)
        this.RefreshNodeStyles(userData, true);
    }
    ((Control) this).ResumeLayout();
  }

  protected virtual void ClearAllMarked()
  {
    ((Control) this).SuspendLayout();
    foreach (RowCol row in (IEnumerable) ((C1FlexGridBase) this).Rows)
    {
      if (row.UserData is CApECBaseNode userData)
        this.RefreshNodeStyles(userData, false);
    }
    ((Control) this).ResumeLayout();
  }

  protected virtual void OnStartEdit(RowColEventArgs e)
  {
    e.Cancel = true;
    if (this.CustomEditRequest != null)
      this.CustomEditRequest((object) this, new CUiECExternalConnectionsGridWrapper.CustomEditRequestEventArgs(e.Row, e.Col));
    if (e.Cancel)
      return;
    ((C1FlexGridBase) this).OnStartEdit(e);
  }

  internal void Initialize() => this.InitColumns();

  internal void Uninitialize() => this.RemoveAllNodes();

  internal void ApplyGridSettings(
    CUiECExternalConnectionsGridWrapper.GridSettings settings)
  {
    if (settings == null)
      return;
    ((ScrollableControl) this).BeginUpdate();
    try
    {
      this.ApplyColumnsWidthSettings(settings);
      this.ApplyColumnsSortSettings(settings);
    }
    finally
    {
      ((ScrollableControl) this).EndUpdate();
    }
  }

  internal void ApplyColumnsWidthSettings(
    CUiECExternalConnectionsGridWrapper.GridSettings settings)
  {
    if (settings.ColumnNameToWidthMap == null)
      return;
    ((ScrollableControl) this).BeginUpdate();
    try
    {
      Dictionary<string, int>.Enumerator enumerator = settings.ColumnNameToWidthMap.GetEnumerator();
      while (enumerator.MoveNext())
      {
        KeyValuePair<string, int> current = enumerator.Current;
        string key = current.Key;
        current = enumerator.Current;
        int num = current.Value;
        if (((C1FlexGridBase) this).Cols.Contains(key))
          ((C1FlexGridBase) this).Cols[key].Width = num;
      }
    }
    finally
    {
      ((ScrollableControl) this).EndUpdate();
    }
  }

  internal void ApplyColumnsSortSettings(
    CUiECExternalConnectionsGridWrapper.GridSettings settings)
  {
    string sortColumnName = settings.SortColumnName;
    if (sortColumnName == null || !((C1FlexGridBase) this).Cols.Contains(sortColumnName))
      return;
    ((C1FlexGridBase) this).Sort(settings.SortFlags, ((RowCol) ((C1FlexGridBase) this).Cols[sortColumnName]).Index);
  }

  internal CUiECExternalConnectionsGridWrapper.GridSettings RetrieveActualGridSettings()
  {
    Dictionary<string, int> columnNameToWidthMap = new Dictionary<string, int>(((RowColCollection) ((C1FlexGridBase) this).Cols).Count);
    int num = ((RowColCollection) ((C1FlexGridBase) this).Cols).Count - 1;
    foreach (Column col in (IEnumerable) ((C1FlexGridBase) this).Cols)
    {
      bool flag = true;
      if (((C1FlexGridBase) this).ExtendLastCol)
        flag = ((RowCol) col).Index != num;
      if (flag)
        columnNameToWidthMap.Add(col.Name, col.Width);
    }
    string sortColumnName = ((C1FlexGridBase) this).SortColumn != null ? ((C1FlexGridBase) this).SortColumn.Name : string.Empty;
    SortFlags sort = ((C1FlexGridBase) this).SortColumn != null ? ((C1FlexGridBase) this).SortColumn.Sort : (SortFlags) (object) 0;
    return new CUiECExternalConnectionsGridWrapper.GridSettings(columnNameToWidthMap, sortColumnName, sort);
  }

  internal void ClearSelection()
  {
    if (((RowColCollection) ((C1FlexGridBase) this).Rows.Selected).Count <= 0)
      return;
    ((ScrollableControl) this).BeginUpdate();
    try
    {
      foreach (Row row in (IEnumerable) ((C1FlexGridBase) this).Rows.Selected)
      {
        if (((RowCol) row).Selected)
          ((RowCol) row).Selected = false;
      }
    }
    finally
    {
      ((ScrollableControl) this).EndUpdate();
    }
  }

  internal void SelectNode(CApECBaseNode node, bool clearPreviousSelection)
  {
    if (node.Row == null)
      return;
    if (clearPreviousSelection)
    {
      ((ScrollableControl) this).BeginUpdate();
      try
      {
        this.ClearSelection();
        ((RowCol) node.Row).Selected = true;
      }
      finally
      {
        ((ScrollableControl) this).EndUpdate();
      }
    }
    else
      ((RowCol) node.Row).Selected = true;
  }

  internal void SelectNodes(List<CApECBaseNode> nodes, bool clearPreviousSelection)
  {
    if (nodes.Count <= 0)
      return;
    ((ScrollableControl) this).BeginUpdate();
    try
    {
      if (clearPreviousSelection)
        this.ClearSelection();
      foreach (CApECBaseNode node in nodes)
      {
        if (node.Row != null)
          ((RowCol) node.Row).Selected = true;
      }
    }
    finally
    {
      ((ScrollableControl) this).EndUpdate();
    }
  }

  internal void DeselectNode(CApECBaseNode node)
  {
    if (node.Row == null)
      return;
    ((RowCol) node.Row).Selected = false;
  }

  internal void DeselectNodes(List<CApECBaseNode> nodes)
  {
    if (nodes.Count <= 0)
      return;
    ((ScrollableControl) this).BeginUpdate();
    try
    {
      foreach (CApECBaseNode node in nodes)
        this.DeselectNode(node);
    }
    finally
    {
      ((ScrollableControl) this).EndUpdate();
    }
  }

  internal bool IsSelectedRow(int rowIndex)
  {
    bool flag = false;
    if (rowIndex >= 0 && rowIndex < ((RowColCollection) ((C1FlexGridBase) this).Rows).Count)
      flag = ((RowCol) ((C1FlexGridBase) this).Rows[rowIndex]).Selected;
    return flag;
  }

  internal bool IsNodeRow(int rowIndex) => this.NodeAt(rowIndex) != null;

  internal bool IsConnectionNodeRow(int rowIndex) => this.ConnectionNodeAt(rowIndex) != null;

  internal CApECBaseNode NodeAt(int rowIndex)
  {
    CApECBaseNode capEcBaseNode = (CApECBaseNode) null;
    if (rowIndex >= 0 && rowIndex < ((RowColCollection) ((C1FlexGridBase) this).Rows).Count)
      capEcBaseNode = ((RowCol) ((C1FlexGridBase) this).Rows[rowIndex]).UserData as CApECBaseNode;
    return capEcBaseNode;
  }

  internal CApECExternalConnectionNode ConnectionNodeAt(int rowIndex)
  {
    CApECExternalConnectionNode externalConnectionNode = (CApECExternalConnectionNode) null;
    if (rowIndex >= 0 && rowIndex < ((RowColCollection) ((C1FlexGridBase) this).Rows).Count)
      externalConnectionNode = ((RowCol) ((C1FlexGridBase) this).Rows[rowIndex]).UserData as CApECExternalConnectionNode;
    return externalConnectionNode;
  }

  internal object ColumnDataAt(int colIndex)
  {
    object obj = (object) null;
    if (colIndex >= 0 && colIndex < ((RowColCollection) ((C1FlexGridBase) this).Cols).Count)
      obj = ((RowCol) ((C1FlexGridBase) this).Cols[colIndex]).UserData;
    return obj;
  }

  internal Row InsertNode(CApECBaseNode node, int rowIndex)
  {
    Row row = ((C1FlexGridBase) this).Rows.Insert(rowIndex);
    ((RowCol) row).UserData = (object) node;
    node.Row = row;
    this.UpdateNode(node);
    return row;
  }

  internal void InsertNodes(List<CApECBaseNode> nodes, int insertRowIndex)
  {
    if (nodes.Count <= 0)
      return;
    ((ScrollableControl) this).BeginUpdate();
    try
    {
      int rowIndex = insertRowIndex;
      foreach (CApECBaseNode node in nodes)
        rowIndex = ((RowCol) this.InsertNode(node, rowIndex)).Index + 1;
    }
    finally
    {
      ((ScrollableControl) this).EndUpdate();
    }
  }

  internal void RemoveNode(CApECBaseNode node)
  {
    ((C1FlexGridBase) this).Rows.Remove(node.Row);
    if (((RowColCollection) ((C1FlexGridBase) this).Rows).Count != ((RowColCollection) ((C1FlexGridBase) this).Rows).Fixed)
      return;
    ((C1FlexGridBase) this).Select(-1, -1);
  }

  internal void RemoveNodes(List<CApECBaseNode> nodes)
  {
    if (nodes.Count <= 0)
      return;
    ((ScrollableControl) this).BeginUpdate();
    try
    {
      foreach (CApECBaseNode node in nodes)
        this.RemoveNode(node);
    }
    finally
    {
      ((ScrollableControl) this).EndUpdate();
    }
  }

  internal void RemoveConnectionNodes(List<CApECExternalConnectionNode> connectionNodes)
  {
    if (connectionNodes.Count <= 0)
      return;
    ((ScrollableControl) this).BeginUpdate();
    try
    {
      foreach (CApECBaseNode connectionNode in connectionNodes)
        this.RemoveNode(connectionNode);
    }
    finally
    {
      ((ScrollableControl) this).EndUpdate();
    }
  }

  internal void RemoveAllNodes() => this.RemoveNodes(this.Nodes);

  internal void UpdateNode(CApECBaseNode node)
  {
    if (node is CApECExternalConnectionNode externalConnectionNode)
    {
      IApECExternalConnectionDataConvertor connectionDataConvertor = (IApECExternalConnectionDataConvertor) new CApECExternalConnectionDataGridConvertor(externalConnectionNode.Connection.Data);
      int index = ((RowCol) externalConnectionNode.Row).Index;
      foreach (Column col in (IEnumerable) ((C1FlexGridBase) this).Cols)
      {
        string name = col.Name;
        object obj = (object) null;
        switch (name)
        {
          case "Column_Name":
            obj = connectionDataConvertor.Name;
            break;
          case "Column_Type":
            obj = connectionDataConvertor.Type;
            break;
          case "Column_OpcServer":
            obj = connectionDataConvertor.OpcServer;
            break;
          case "Column_ItemHeader":
            obj = connectionDataConvertor.ItemHeader;
            break;
          case "Column_NameSpaceIndex":
            obj = connectionDataConvertor.NameSpaceIndex;
            break;
          case "Column_InstanceName":
            obj = connectionDataConvertor.InstanceName;
            break;
          case "COMM_Element":
            obj = connectionDataConvertor.COMElement;
            break;
          case "Column_MapSignalsBy":
            obj = connectionDataConvertor.MapSignalsBy;
            break;
        }
        ((C1FlexGridBase) this)[index, ((RowCol) col).Index] = obj;
      }
    }
    this.RefreshNodeStyles(node, ((RowCol) node.Row).Selected);
  }

  internal void UpdateNodes(List<CApECBaseNode> nodes)
  {
    if (nodes.Count <= 0)
      return;
    ((ScrollableControl) this).BeginUpdate();
    try
    {
      foreach (CApECBaseNode node in nodes)
        this.UpdateNode(node);
    }
    finally
    {
      ((ScrollableControl) this).EndUpdate();
    }
  }

  internal void UpdateAllNodes() => this.UpdateNodes(this.Nodes);

  private void InitColumns()
  {
    ((ScrollableControl) this).BeginUpdate();
    try
    {
      string empty = string.Empty;
      ColumnCollection cols = ((C1FlexGridBase) this).Cols;
      string colName1 = "Column_Name";
      if (cols.Contains(colName1))
      {
        Column column = cols[colName1];
        column.Caption = CUiECExternalConnectionsResourceTable.GRID_COLUMN_CAPTION_NAME;
        ((RowCol) column).UserData = (object) CApECGeneralUtils.eColumnDataType.Name;
        this.InitCustomStyles(colName1);
      }
      string colName2 = "Column_Type";
      if (cols.Contains(colName2))
      {
        Column column = cols[colName2];
        column.Caption = CUiECExternalConnectionsResourceTable.GRID_COLUMN_CAPTION_TYPE;
        ((RowCol) column).UserData = (object) CApECGeneralUtils.eColumnDataType.Type;
        this.InitCustomStyles(colName2);
      }
      string colName3 = "Column_OpcServer";
      if (cols.Contains(colName3))
      {
        Column column = cols[colName3];
        column.Caption = CUiECExternalConnectionsResourceTable.GRID_COLUMN_CAPTION_OPC_SERVER;
        ((RowCol) column).UserData = (object) CApECGeneralUtils.eColumnDataType.OpcServer;
        this.InitCustomStyles(colName3);
      }
      string colName4 = "Column_ItemHeader";
      if (cols.Contains(colName4))
      {
        Column column = cols[colName4];
        column.Caption = CUiECExternalConnectionsResourceTable.GRID_COLUMN_CAPTION_ITEM_HEADER;
        ((RowCol) column).UserData = (object) CApECGeneralUtils.eColumnDataType.ItemHeader;
        this.InitCustomStyles(colName4);
      }
      string colName5 = "Column_NameSpaceIndex";
      if (cols.Contains(colName5))
      {
        Column column = cols[colName5];
        column.Caption = CUiECExternalConnectionsResourceTable.GRID_COLUMN_CAPTION_NAME_SPACE_INDEX;
        ((RowCol) column).UserData = (object) CApECGeneralUtils.eColumnDataType.NameSpaceIndex;
        this.InitCustomStyles(colName5);
      }
      string colName6 = "Column_InstanceName";
      if (cols.Contains(colName6))
      {
        Column column = cols[colName6];
        column.Caption = CUiECExternalConnectionsResourceTable.GRID_COLUMN_CAPTION_INSTANCE_NAME;
        ((RowCol) column).UserData = (object) CApECGeneralUtils.eColumnDataType.InstanceName;
        this.InitCustomStyles(colName6);
      }
      string colName7 = "COMM_Element";
      if (cols.Contains(colName7))
      {
        Column column = cols[colName7];
        column.Caption = CUiECExternalConnectionsResourceTable.GRID_COLUMN_CAPTION_COM_ELEMENT;
        ((RowCol) column).UserData = (object) CApECGeneralUtils.eColumnDataType.COMElement;
        this.InitCustomStyles(colName7);
      }
      string colName8 = "Column_MapSignalsBy";
      if (!cols.Contains(colName8))
        return;
      Column column1 = cols[colName8];
      column1.Caption = CUiECExternalConnectionsResourceTable.GRID_COLUMN_CAPTION_MAP_SIGNALS_BY;
      ((RowCol) column1).UserData = (object) CApECGeneralUtils.eColumnDataType.MapSignalsBy;
      this.InitCustomStyles(colName8);
    }
    finally
    {
      ((ScrollableControl) this).EndUpdate();
    }
  }

  private void InitCustomStyles(string colName)
  {
    if (!((C1FlexGridBase) this).Cols.Contains(colName))
      return;
    Column col = ((C1FlexGridBase) this).Cols[colName];
    string str1 = string.Empty;
    string str2 = string.Empty;
    if (colName == "Column_Name")
    {
      str1 = "connectionName_Normal";
      str2 = "connectionName_Select";
    }
    if (colName == "Column_Type")
    {
      str1 = "connectionType_Normal";
      str2 = "connectionType_Select";
    }
    else if (colName == "Column_OpcServer")
    {
      str1 = "opcServer_Normal";
      str2 = "opcServer_Select";
    }
    else if (colName == "Column_ItemHeader")
    {
      str1 = "itemHeader_Normal";
      str2 = "itemHeader_Select";
    }
    else if (colName == "Column_NameSpaceIndex")
    {
      str1 = "namespaceIndex_Normal";
      str2 = "namespaceIndex_Select";
    }
    else if (colName == "Column_InstanceName")
    {
      str1 = "instanceName_Normal";
      str2 = "instanceName_Select";
    }
    else if (colName == "COMM_Element")
    {
      str1 = "comElement_Normal";
      str2 = "comElement_Select";
    }
    else if (colName == "Column_MapSignalsBy")
    {
      str1 = "mapSignalsBy_Normal";
      str2 = "mapSignalsBy_Select";
    }
    if (str1 != string.Empty)
    {
      CellStyle cellStyle = ((C1FlexGridBase) this).Styles.Add(str1, ((RowCol) col).StyleDisplay);
      cellStyle.ForeColor = ((C1FlexGridBase) this).Styles[(CellStyleEnum) 0].ForeColor;
      cellStyle.BackColor = ((C1FlexGridBase) this).Styles[(CellStyleEnum) 0].BackColor;
    }
    if (!(str2 != string.Empty))
      return;
    CellStyle cellStyle1 = ((C1FlexGridBase) this).Styles.Add(str2, ((RowCol) col).StyleDisplay);
    cellStyle1.ForeColor = ((C1FlexGridBase) this).Styles[(CellStyleEnum) 3].ForeColor;
    cellStyle1.BackColor = ((C1FlexGridBase) this).Styles[(CellStyleEnum) 3].BackColor;
  }

  private void RefreshNodeStyles(CApECBaseNode node, bool selected)
  {
    if (!(node is CApECExternalConnectionNode connectionNode))
      return;
    foreach (Column col in (IEnumerable) ((C1FlexGridBase) this).Cols)
    {
      CellStyle connectionCellStyle = this.GetCustomConnectionCellStyle(connectionNode, col, selected);
      ((C1FlexGridBase) this).SetCellStyle(((RowCol) connectionNode.Row).Index, ((RowCol) col).Index, connectionCellStyle);
    }
  }

  private CellStyle GetCustomConnectionCellStyle(
    CApECExternalConnectionNode connectionNode,
    Column col,
    bool selected)
  {
    CellStyle connectionCellStyle = (CellStyle) null;
    if (connectionNode != null)
    {
      string str = string.Empty;
      object obj = this.ColumnDataAt(((RowCol) col).Index);
      if (obj != null && obj.GetType() == typeof (CApECGeneralUtils.eColumnDataType))
      {
        switch ((CApECGeneralUtils.eColumnDataType) obj)
        {
          case CApECGeneralUtils.eColumnDataType.Name:
            str = selected ? "connectionName_Select" : "connectionName_Normal";
            break;
          case CApECGeneralUtils.eColumnDataType.Type:
            str = selected ? "connectionType_Select" : "connectionType_Normal";
            break;
          case CApECGeneralUtils.eColumnDataType.OpcServer:
            str = selected ? "opcServer_Select" : "opcServer_Normal";
            break;
          case CApECGeneralUtils.eColumnDataType.ItemHeader:
            str = selected ? "itemHeader_Select" : "itemHeader_Normal";
            break;
          case CApECGeneralUtils.eColumnDataType.NameSpaceIndex:
            str = selected ? "namespaceIndex_Select" : "namespaceIndex_Normal";
            break;
          case CApECGeneralUtils.eColumnDataType.InstanceName:
            str = selected ? "instanceName_Select" : "instanceName_Normal";
            break;
          case CApECGeneralUtils.eColumnDataType.COMElement:
            str = selected ? "comElement_Select" : "comElement_Normal";
            break;
          case CApECGeneralUtils.eColumnDataType.MapSignalsBy:
            str = selected ? "mapSignalsBy_Select" : "mapSignalsBy_Normal";
            break;
        }
        if (str != string.Empty)
          connectionCellStyle = ((C1FlexGridBase) this).Styles[str];
      }
    }
    return connectionCellStyle;
  }

  protected virtual void Dispose(bool disposing)
  {
    if (disposing && this.components != null)
      this.components.Dispose();
    ((TxFlexGrid) this).Dispose(disposing);
  }

  private void InitializeComponent()
  {
  }

  internal class GridSettings
  {
    internal readonly Dictionary<string, int> ColumnNameToWidthMap;
    internal readonly string SortColumnName;
    internal readonly SortFlags SortFlags;

    internal GridSettings(
      Dictionary<string, int> columnNameToWidthMap,
      string sortColumnName,
      SortFlags sortFlags)
    {
      this.ColumnNameToWidthMap = columnNameToWidthMap;
      this.SortColumnName = sortColumnName;
      this.SortFlags = sortFlags;
    }
  }

  internal class CustomEditRequestEventArgs
  {
    internal readonly int Row;
    internal readonly int Col;
    internal bool Handled;

    internal CustomEditRequestEventArgs(int row, int col)
    {
      this.Row = row;
      this.Col = col;
      this.Handled = false;
    }
  }

  internal delegate void CustomEditRequestEventHandler(
    object sender,
    CUiECExternalConnectionsGridWrapper.CustomEditRequestEventArgs e);
}
